Conversation
7ddb4e9 to
587d578
Compare
587d578 to
52d7aa7
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for verifying webhook signatures via HMAC-SHA256, including implementation of the verifier and accompanying tests, a simple test server, and updated documentation.
- Added WebhookVerifier and WebhookSignatureException for signature verification
- Implemented unit tests in WebhookVerifierTest and an HTTP test server in WebhookTestServer
- Updated README.md with usage instructions for verifying webhook signatures
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/com/schematic/webhook/WebhookVerifierTest.java | Added tests to ensure correct signature computation and verification |
| src/main/java/com/schematic/webhook/server/WebhookTestServer.java | Introduced a test server to simulate webhook requests and verify signatures |
| src/main/java/com/schematic/webhook/WebhookVerifier.java | Implemented webhook signature verification logic using HMAC-SHA256 |
| src/main/java/com/schematic/webhook/WebhookSignatureException.java | Created a custom exception for signature verification failures |
| README.md | Updated documentation with instructions for webhook signature verification |
Files not reviewed (1)
- .fernignore: Language not supported
Comment on lines
+137
to
+138
| exchange.sendResponseHeaders(statusCode, body.length()); | ||
|
|
There was a problem hiding this comment.
Consider using body.getBytes(StandardCharsets.UTF_8).length instead of body.length() when setting the response header to accurately calculate the number of bytes, especially for non-ASCII characters.
Suggested change
| exchange.sendResponseHeaders(statusCode, body.length()); | |
| exchange.sendResponseHeaders(statusCode, body.getBytes(StandardCharsets.UTF_8).length); |
| * @return The byte array | ||
| * @throws WebhookSignatureException if the hex string is invalid | ||
| */ | ||
| private static byte[] hexToBytes(String hex) throws WebhookSignatureException { |
There was a problem hiding this comment.
It would be beneficial to validate that the hex string has an even length before processing, as an odd-length string would indicate an invalid format.
Suggested change
| private static byte[] hexToBytes(String hex) throws WebhookSignatureException { | |
| private static byte[] hexToBytes(String hex) throws WebhookSignatureException { | |
| if (hex.length() % 2 != 0) { | |
| throw new WebhookSignatureException("Invalid hex string format: length must be even"); | |
| } |
dontlaugh
approved these changes
Mar 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.